home *** CD-ROM | disk | FTP | other *** search
/ Video Toaster 4.2 / Video Toaster v4.2.iso / programs / documentation / lightwave / formatlwob.txt < prev    next >
Text File  |  1995-05-18  |  17KB  |  390 lines

  1.                    LIGHTWAVE 3D OBJECT FILE FORMAT
  2.  
  3.                           by Allen Hastings
  4.               & Stuart Ferguson
  5.                           revised  11/28/94
  6.  
  7.  
  8. Introduction
  9.  
  10.   LightWave 3D objects are stored as IFF files with a FORM type of
  11.   LWOB.  A FORM LWOB must contain a PNTS chunk, a SRFS chunk, and a
  12.   POLS chunk.  There may be zero or more SURF chunks anywhere in the
  13.   file and up to one CRVS chunk.  The POLS and CRVS chunks must be
  14.   preceded by the PNTS chunk and the SRFS chunk.  LightWave 2.0 also
  15.   has the ability to save and load surface descriptions as FORM LWOB
  16.   files that contain only a SURF chunk.
  17.  
  18.   This document explains the contents of each chunk and includes an
  19.   annotated listing of a FORM LWOB as an example.
  20.  
  21.  
  22. PNTS Chunk
  23.  
  24.   This chunk contains a list of the X, Y, and Z coordinates of all
  25.   the points in an object.  Each coordinate is stored as a four byte
  26.   floating point number in IEEE format.  Therefore, the number of
  27.   points in an object can be determined by dividing the size in bytes
  28.   of the PNTS chunk by 12.
  29.  
  30.   By convention, the +X direction is to the right or east, the +Y
  31.   direction is upward, and the +Z direction is forward or north.
  32.   For models of real-world objects, the unit size is usually
  33.   considered to be one meter.  The coordinates are specified relative
  34.   to an object's pivot point.  See the LightWave Modeler manual for
  35.   more information about LightWave 3D's geometric conventions.
  36.  
  37.  
  38. SRFS Chunk
  39.  
  40.   This chunk contains a list of the names of all the surfaces in an
  41.   object (note that in LightWave 3D terminology, the word "surface"
  42.   is defined as a set of attributes that describe the color and
  43.   shading characteristics of a group of polygons).  Each surface name
  44.   appears as a null-terminated character string.  If the length of
  45.   the string (including the null) is odd, an extra null byte is
  46.   added.  Surface names should be read from the file until as many
  47.   bytes as the chunk size specifies have been read.
  48.  
  49.  
  50. POLS Chunk
  51.  
  52.   This chunk contains a list of all the polygons in an object.  Each
  53.   entry consists of a short integer specifying the number of vertices
  54.   in a polygon followed by that many short integers specifying the
  55.   vertices themselves (as indices into the points list) followed by a
  56.   short integer specifying which surface is used by the polygon (as
  57.   an index into the surfaces list).  The number of vertices in a
  58.   polygon currently may vary from one to 200.  The vertex list for
  59.   each polygon should begin at a convex vertex and proceed clockwise
  60.   as seen from the visible side of the polygon (LightWave 3D polygons
  61.   are single-sided, except for those whose surfaces have the double-
  62.   sided flag set).  The points list in the PNTS chunk is numbered
  63.   starting with zero and the surfaces list in the SRFS chunk is
  64.   numbered starting with one (so that surface numbers can be made
  65.   negative to signal the presence of detail polygons as explained
  66.   below).  Polygons should be read from the file until as many bytes
  67.   as the chunk size specifies have been read.
  68.  
  69.   A negative surface number for a polygon indicates that the polygon
  70.   has detail polygons (which are drawn on top of the main polygon and
  71.   may be coplanar with it).  In this case, the next number in the
  72.   file is a short integer specifying how many detail polygons belong
  73.   to the current polygon.  This is followed by a list of those detail
  74.   polygons, where each entry is of the same format as described above
  75.   for regular polygons (except that the detail polygons cannot have
  76.   details of their own).  The list of regular polygons then resumes.
  77.   To determine which surface is used by a polygon with a negative
  78.   surface number, the absolute value of that number should be used.
  79.  
  80.  
  81. CRVS Chunks
  82.  
  83.   This chunk contains a list of all the spline curves in an object. 
  84.   Each entry consists of a short integer specifying the number of
  85.   vertices in a curve followed by that many short integers specifying
  86.   the vertices themselves in sequential order, followed by a short
  87.   integer specifying which surface is used by the curve, followed by
  88.   another short integer specifying bit-flags associated with the
  89.   curve.  If bit zero is set then the first point is a continuity
  90.   control point, and if bit one is set then the last point is.  The
  91.   point and surface indices are as they are in the POLS chunk, except
  92.   that curves cannot have details.  Curves should be read from the
  93.   file until as many bytes as the chunk size specifies have been read.
  94.  
  95.  
  96. SURF Chunks
  97.  
  98.   Each SURF chunk describes the surface attributes of a particular
  99.   surface.  These chunks begin with the name of the surface being
  100.   described.  The name is stored as a character string with either
  101.   one or two trailing nulls (as explained in the SRFS chunk section).
  102.   Following the name is a series of sub-chunks, which are like normal
  103.   IFF chunks except that their sizes are specified by short integers
  104.   instead of longs.  It is likely that the variety of sub-chunks will
  105.   grow as new surface attributes are added to the program, but any
  106.   unknown sub-chunks may be skipped over in the usual IFF fashion.
  107.   Sub-chunks should be read from the file until as many bytes as the
  108.   chunk size specifies have been read.
  109.  
  110.   COLR Sub-Chunk
  111.  
  112.     This sub-chunk consists of three bytes that specify the red,
  113.     green, and blue color components of the current surface, followed
  114.     by a byte which is currently ignored and should be zero.  A
  115.     surface can therefore be any of 16,777,216 possible colors.
  116.  
  117.   FLAG Sub-Chunk
  118.  
  119.     This sub-chunk contains a short integer whose bits specify
  120.     various options for the current surface.  Currently only the
  121.     nine least significant bits are used.  The options that set bits
  122.     indicate are (starting with the least significant bit):
  123.     Luminous, Outline, Smoothing, Color Highlights, Color Filter,
  124.     Opaque Edge, Transparent Edge, Sharp Terminator, Double Sided,
  125.     and Additive (which is new for LW 3.0).  Note that the two edge
  126.     transparency bits should not both be set.
  127.  
  128.   LUMI, DIFF, SPEC, REFL, and TRAN Sub-Chunks
  129.  
  130.     Each of these sub-chunks contain a short integer that specifies
  131.     the current surface's luminosity, diffuse, specular, reflection,
  132.     or transparency settings (the LUMI sub-chunk is new for LW 3.0,
  133.     and replaces the Luminous bit of the FLAG sub-chunk).  A value of
  134.     256 in the file corresponds to a setting of 100% on the control
  135.     panel.  If any of these sub-chunks are absent for a surface, a
  136.     value of zero is assumed for the corresponding parameter.
  137.  
  138.   GLOS Sub-Chunk
  139.  
  140.     This sub-chunk contains a short integer that specifies the
  141.     glossiness of the current surface, and is only needed if the
  142.     specular setting in the SPEC sub-chunk is non-zero.  A value of
  143.     16 indicates low glossiness, 64 indicates medium glossiness, 256
  144.     indicates high glossiness, and 1024 indicates maximum glossiness
  145.     (the maximum setting is new for LW 3.0).  This parameter is
  146.     related to the "specular exponent" used in many lighting models.
  147.  
  148.   RIMG Sub-Chunk
  149.  
  150.     This sub-chunk contains the filename (including any path the user
  151.     may have specified) of the image to be used as a reflection map
  152.     for the current surface.  Once again, if the length of the string
  153.     (including the terminating null) is odd, another null is added.
  154.     If the last part of the string is " (sequence)", then the first
  155.     part of the string specifies the prefix of an image sequence (the
  156.     actual filename in this case is generated by appending a three
  157.     digit frame number to the prefix when loading the image file for
  158.     each frame).  If the reflection setting in the REFL sub-chunk is
  159.     non-zero but no RIMG sub-chunk is present, then the surface is
  160.     assumed to reflect the sky and ground backdrop (or to use ray
  161.     traced reflection if ray tracing is enabled).
  162.  
  163.   RSAN Sub-Chunk
  164.  
  165.     This sub-chunk contains a four byte IEEE floating point number
  166.     that specifies the heading angle of the reflection map seam
  167.     (expressed in degrees).  This is new for LW 3.0.
  168.  
  169.   RIND Sub-Chunk
  170.  
  171.     This sub-chunk contains a four byte IEEE floating point number
  172.     that specifies the current surface's refractive index, which is
  173.     defined as the ratio of the speed of light in a vacuum to the
  174.     speed of light in the material.  Since light is fastest in a
  175.     vacuum, this value should therefore be greater than or equal to
  176.     1.0.
  177.  
  178.   EDGE Sub-Chunk
  179.  
  180.     This sub-chunk contains a four byte IEEE floating point number
  181.     that specifies the edge transparency threshold of the current
  182.     surface.  This value should lie between 0.0 and 1.0.
  183.  
  184.   SMAN Sub-Chunk
  185.  
  186.     This sub-chunk contains a four byte IEEE floating point number
  187.     that specifies the maximum angle between two adjacent polygons
  188.     that can be smooth shaded (expressed in degrees).  Polygons with
  189.     a greater angle between them will appear to meet at a sharp seam.
  190.     This is new for LW 3.0.
  191.  
  192.   CTEX, DTEX, STEX, RTEX, TTEX, and BTEX Sub-Chunks
  193.  
  194.     The presence of one of these sub-chunks indicates that the
  195.     current surface has a color, diffuse, specular, reflection,
  196.     transparency, or bump texture.  The contents of the sub-chunk is
  197.     a character string (terminated by one or two nulls as usual)
  198.     specifying the texture type as shown on the control panel.  Once
  199.     one of these sub-chunks is encountered within a SURF chunk, all
  200.     subsequent texture-related sub-chunks (those described below) are
  201.     considered to pertain to the current texture, until another CTEX,
  202.     DTEX, STEX, RTEX, TTEX, or BTEX sub-chunk is read.  Currently
  203.     there may be zero or one of each of these sub-chunks (up to six
  204.     textures) in each SURF chunk.
  205.  
  206.   TIMG Sub-Chunk
  207.  
  208.     This sub-chunk specifies the filename of the image (or the prefix
  209.     of the image sequence) to be used for image texture mapping.  See
  210.     the description of the RIMG sub-chunk above for more details.
  211.  
  212.   TFLG Sub-Chunk
  213.  
  214.     This sub-chunk contains a short integer whose bits specify
  215.     various options for the current texture.  Currently only the
  216.     seven least significant bits are used.  The options that set bits
  217.     indicate are (starting with the least significant bit):  X Axis,
  218.     Y Axis, Z Axis, World Coords, Negative Image, Pixel Blending, and
  219.     Antialiasing.  Note that only one of the three axis bits should
  220.     be set.
  221.  
  222.   TSIZ, TCTR, TFAL, and TVEL Sub-Chunks
  223.  
  224.     These sub-chunks each consist of three IEEE four byte floating
  225.     point numbers that specify the X, Y, and Z components of the
  226.     current texture's size, center, falloff, or velocity.  The TCTR,
  227.     TFAL, and TVEL sub-chunks are only needed if the corresponding
  228.     parameters are non-zero.
  229.  
  230.   TCLR Sub-Chunk
  231.  
  232.     This sub-chunk contains four bytes that specify the texture color
  233.     for the current texture, which should be of the color-modifying
  234.     variety (in other words, there should be a CTEX sub-chunk
  235.     somewhere before this sub-chunk).  The bytes are interpreted as
  236.     described above in the COLR sub-chunk section.
  237.  
  238.   TVAL Sub-Chunk
  239.  
  240.     This sub-chunk contains a short integer that specifies the
  241.     texture value of a diffuse, specular, reflection, or transparency
  242.     texture, so it should appear somewhere after a DTEX, STEX, RTEX,
  243.     or TTEX sub-chunk.  A value of 256 in the file corresponds to a
  244.     a setting of 100% on the control panel.
  245.  
  246.   TAMP Sub-Chunk
  247.  
  248.     This sub-chunk contains a four byte IEEE floating point number
  249.     that specifies the amplitude of the current bump texture, so it
  250.     should appear somewhere after a BTEX sub-chunk.  A value of 1.0
  251.     is equivalent to a setting of 100% on the control panel.
  252.  
  253.   TFRQ Sub-Chunk
  254.  
  255.     This sub-chunk contains a short integer that specifies the number
  256.     of noise frequencies or wave sources used by the current texture.
  257.  
  258.   TSP0, TSP1, and TSP2 Sub-Chunks
  259.  
  260.     These sub-chunks each contain a four byte IEEE floating point
  261.     number that specifies one of the special texture type-specific
  262.     parameters (such as Contrast, Turbulence, Wavelength, etc).
  263.     Which sub-chunk is used to record a particular parameter depends
  264.     on the order in which that parameter's button appears on the
  265.     control panel.  In the future there may be more than three of
  266.     these per texture.
  267.  
  268.  
  269. Object File Example
  270.  
  271.   A simple object (with somewhat complex surfaces) is listed below to
  272.   illustrate some of the features of a FORM LWOB.  The object is an
  273.   image-mapped bumpy square polygon in the XY plane with a shiny
  274.   transparent yellow triangle as a detail polygon.  Each line of the
  275.   listing shows 16 bytes in hexadecimal form followed by their ASCII
  276.   equivalents.  The notes under each line should be read from left to
  277.   right rather than top to bottom.
  278.  
  279.   464F524D 0000019C 4C574F42 504E5453    FORM....LWOBPNTS
  280.   00000054 3F800000 3F800000 00000000    ...T?...?.......
  281.            ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
  282.            The X, Y, and Z coordinates of point number zero are 1.0,
  283.            1.0, and 0.0 (in IEEE format).
  284.       ^^^^
  285.       There are 84 bytes in the PNTS chunk, so there are seven points
  286.       in the object.
  287.  
  288.   BF800000 3F800000 00000000 3F800000    ....?.......?...
  289.   BF800000 00000000 BF800000 BF800000    ................
  290.   00000000 3F000000 BF000000 00000000    ....?...........
  291.   00000000 3F000000 00000000 BF000000    ....?...........
  292.   BF000000 00000000 53524653 00000012    ........SRFS....
  293.   53717561 72650000 54726961 6E676C65    Square..Triangle
  294.                ^^^^
  295.                The surface name "Square" is terminated with two nulls
  296.                to even out the number of bytes.
  297.  
  298.   0000504F 4C530000 00180004 00010000    ..POLS..........
  299.                         ^^^^
  300.                         The first polygon has four vertices (which
  301.                         are points 1, 0, 2, and 3).
  302.  
  303.   00020003 FFFF0001 00030005 00040006    ................
  304.                     ^^^^
  305.                     The detail polygon has three vertices (which are
  306.                     points 5, 4, and 6).
  307.                ^^^^
  308.                One detail polygon follows.
  309.            ^^^^
  310.            The first polygon's surface code is -1, so it uses surface
  311.            number one ("Square") and has detail polygons.
  312.  
  313.   00025355 52460000 00AE5371 75617265    ..SURF....Square
  314.       ^^^^ ^^^^
  315.       This begins the description of the surface called "Square".
  316.   ^^^^
  317.   The detail polygon uses surface number two ("Triangle").
  318.  
  319.   0000434F 4C520004 C8C8C800 464C4147    ..COLR......FLAG
  320.   00020000 44494646 00020100 43544558    ....DIFF....CTEX
  321.                              ^^^^^^^^
  322.                              The next set of texture sub-chunks
  323.                              pertain to the surface's color texture.
  324.                         ^^^^
  325.                         The "Square" surface's diffuse setting is
  326.                         100% (256 out of 256).
  327.  
  328.   0012506C 616E6172 20496D61 6765204D    ..Planar Image M
  329.       ^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^
  330.       The color texture is planar mapping of the image in the IFF
  331.       file "RAM:Laura".
  332.  
  333.   61700000 54494D47 000A5241 4D3A4C61    ap..TIMG..RAM:La
  334.   75726100 54464C47 00020004 5453495A    ura.TFLG....TSIZ
  335.                         ^^^^
  336.                         The flag bits indicate that the image is to
  337.                         be projected along the Z axis.
  338.  
  339.   000C4000 00003FC0 00003F80 00005443    ..@...?...?...TC
  340.       ^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^
  341.       The X, Y, and Z texture sizes are 2.0, 1.5, and 1.0.
  342.  
  343.   4C520004 00000000 42544558 000E4672    LR......BTEX..Fr
  344.                     ^^^^^^^^
  345.                     The next set of texture sub-chunks pertain to the
  346.                     "Square" surface's bump texture.
  347.  
  348.   61637461 6C204275 6D707300 54464C47    actal Bumps.TFLG
  349.   0002000A 5453495A 000C3DCC CCCD3DCC    ....TSIZ..=...=.
  350.       ^^^^
  351.       The flag bits indicate that "Worlds Coords" is turned on.
  352.  
  353.   CCCD3DCC CCCD5441 4D500004 3FC00000    ..=...TAMP..?...
  354.                              ^^^^^^^^
  355.                              The amplitude of the bumps is 150% (1.5
  356.                              in IEEE format).
  357.  
  358.   54465251 00020001 53555246 00000044    TFRQ....SURF...D
  359.                     ^^^^^^^^
  360.                     This begins the description of the surface called
  361.                     "Triangle".
  362.                ^^^^
  363.                The bump texture uses one frequency of noise.
  364.  
  365.   54726961 6E676C65 0000434F 4C520004    Triangle..COLR..
  366.   F0B40000 464C4147 00020000 44494646    ....FLAG....DIFF
  367.   ^^^^^^^^
  368.   The "Triangle" surface's color is yellow (240 red, 180 green, and 0
  369.   blue).
  370.  
  371.   0002009A 53504543 000200CD 474C4F53    ....SPEC....GLOS
  372.                         ^^^^
  373.                         The surface's specular setting is 80 % (205
  374.                         out of 256).
  375.  
  376.   00020100 5245464C 00020033 5452414E    ....REFL...3TRAN
  377.                         ^^^^
  378.                         The surface's reflection map setting is 20%
  379.                         (51 out of 256), but there is no RIMG sub-
  380.                         chunk, so the surface reflects the backdrop.
  381.       ^^^^
  382.       The surface has a high glossiness (256).
  383.  
  384.   00020066                               ...f
  385.       ^^^^
  386.       The surface is 40% transparent (102 out of 256).
  387.  
  388.   The "Triangle" surface has no textures, and there are no more
  389.   surfaces to be defined, so the object file ends here.
  390.